package com.icehand.canal.handler;

import com.alibaba.otter.canal.protocol.CanalEntry;
import org.springframework.lang.NonNull;

import java.util.Objects;

/**
 * @author icehand
 */
public interface SimpleCanalHandler extends CanalHandler {
    @Override
    default void handle(@NonNull CanalEntry.EventType type, CanalEntry.RowData data){
        Objects.requireNonNull(type,"canal event type is null");
        switch (type) {
            case INSERT:
                insert(data);
                break;
            case UPDATE:
                update(data);
                break;
            case DELETE:
                delete(data);
                break;
            default:
                break;
        }

    }

    void insert(CanalEntry.RowData data);

    void update(CanalEntry.RowData data);

    void delete(CanalEntry.RowData data);
}
